var path = require('path');

var htmlWebpackPlugin = require('html-webpack-plugin');
var OpenBrowserPlugin = require('open-browser-webpack-plugin');



//向外暴露配置对象
module.exports = {
    entry: path.join(__dirname,'./src/main.js'), //制定入口文件
    output: {  //打包的输出选项
        path: path.join(__dirname,'./dist'),  //指定输出路径
        filename: 'bundle.js'  //指定输出文件名称
    },
    plugins: [
        new htmlWebpackPlugin({
            template: path.join(__dirname,'./src/index.html'),
            filename: 'index.html' //指定页面中生成的页面的名称
        }),
        new OpenBrowserPlugin({
            url: 'http://localhost:3001', browser: 'chrome'
        })
    ],
    module: { //第三方loader模块
        rules: [
            { test: /\.css$/, use:['style-loader','css-loader'] },
            { test: /\.less$/,use: ['style-loader', 'css-loader','less-loader']},
            { test: /\.scss$/,use: ['style-loader', 'css-loader','sass-loader']},
            { test: /\.(png|gif|jpg|bmp|jpeg)$/,use: 'url-loader'},
            { test: /\.(ttf|eot|svg|woff|woff2)$/,use: 'url-loader'},
            { test: /\.js$/, use: 'babel-loader', exclude: /node_modules/ },
            { test: /\.vue$/, use: 'vue-loader'}
        ]
    }
}